﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Windows.Forms;

namespace WinFormUtilHelpV2
{
    public static class TabControlToolV2
    {
        /// <summary>
        /// 显示TabPage
        /// </summary>
        /// <param name="tabControl">TabControl对象</param>
        /// <param name="tabpage">需要显示的TabPage</param>
        public static void SetTabPagesVisible(this TabControl tabControl, TabPage tabpage)
        {
            try
            {
                if (tabControl == null)
                    throw new ArgumentNullException("tabControl");
                if (tabpage == null)
                    throw new ArgumentNullException("tabpage");
                tabControl.TabPages.Clear();
                tabControl.TabPages.Add(tabpage);
            }
            catch (ArgumentNullException ex)
            {
                throw ex;
            }
            catch (Exception ex)
            {
                throw new Exception(string.Format("SetTabPagesVisible Exception:{0}", ex.Message.Trim()));
            }
        }
    }
}
